package com.sky.mapper;

import com.sky.dto.ShoppingCartDTO;
import com.sky.entity.Dish;
import com.sky.entity.Setmeal;
import com.sky.entity.ShoppingCart;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.List;

@Mapper
public interface ShoppingCartMapper {

    List<ShoppingCart> getCar(Long currentId);

    void add(ShoppingCart shoppingCar);

    BigDecimal getDishAmount(Long dishId);

    BigDecimal getSetmealAmount(Long setmealId);

    @Select("select count(*) from shopping_cart where dish_id=#{dish_id}")
    int searchHavingDish(ShoppingCartDTO shoppingCartDTO);

    @Select("select count(*) from shopping_cart where setmeal_id=#{setmeal_id}")
    int searchHavingSetmeal(ShoppingCartDTO shoppingCartDTO);

    void changeCar(Long dishId, int number);

    @Select("select number from shopping_cart where dish_id=#{dishId}")
    int numberGet(Long dishId);

    void changeMon(Long dishId, BigDecimal amount);

    @Select("select number from shopping_cart where setmeal_id=#{setmealId}")
    int numberGetSetmeal(Long setmealId);

    ShoppingCart HavingInCar(ShoppingCartDTO shoppingCartDTO, Long userId);

    //此处ID是主键id不是用户id
    void UpdateNumber(ShoppingCart shoppingCart);

    @Select(" select * from setmeal where id = #{setmealId}")
    Setmeal getSetmeal(Long setmealId);

    @Select(" select * from dish where id = #{dishID}")
    Dish getDish(Long dishID);

    void SubCar(ShoppingCart shoppingCart);

    void jianyi(ShoppingCart shoppingCart);

    @Delete("delete from shopping_cart where user_id=#{id}")
    void clean(Long id);

    List<ShoppingCart> GetByUserid(Long userId);
}
